Skip to content

feat(tool): 推断 MCP session_affinity 以支持 MCP_REMOTE proxy 模式#111

Merged
OhYee merged 2 commits into
Serverless-Devs:mainfrom
117503445:fix/mcp-remote-proxy-streamable-endpoint
Jun 2, 2026
Merged

feat(tool): 推断 MCP session_affinity 以支持 MCP_REMOTE proxy 模式#111
OhYee merged 2 commits into
Serverless-Devs:mainfrom
117503445:fix/mcp-remote-proxy-streamable-endpoint

Conversation

@117503445
Copy link
Copy Markdown
Contributor

Signed-off-by: 黑曜 haotian.qht@alibaba-inc.com

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

Signed-off-by: 黑曜 <haotian.qht@alibaba-inc.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds inference of MCP session_affinity from protocol_spec for the MCP_REMOTE + proxy_enabled scenario when mcp_config.session_affinity is empty, so the proxy mode can correctly route to streamable-http upstream MCP servers.

Changes:

  • Add _infer_protocol_spec_mcp_session_affinity helper that parses protocol_spec.mcpServers[*].transportType to derive MCP_STREAMABLE / MCP_SSE.
  • Update _get_mcp_endpoint to call the inference when session_affinity is empty under MCP_REMOTE proxy mode, falling back to MCP_SSE.
  • Add unit tests covering inference for missing and empty session_affinity.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
agentrun/tool/tool.py Adds inference helper and integrates it into _get_mcp_endpoint.
agentrun/tool/__tool_async_template.py Mirrors the same change in the async template (codegen source).
tests/unittests/tool/test_tool.py Adds two test cases covering proxy-mode streamable inference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@117503445 117503445 force-pushed the fix/mcp-remote-proxy-streamable-endpoint branch 2 times, most recently from 292cb08 to b26e01b Compare June 2, 2026 08:07
Signed-off-by: 117503445 <t117503445@gmail.com>
@117503445 117503445 force-pushed the fix/mcp-remote-proxy-streamable-endpoint branch from b26e01b to 2656ee2 Compare June 2, 2026 08:10
@OhYee OhYee merged commit c3d6b80 into Serverless-Devs:main Jun 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants